<template>
  <svg :class="state.svgClass">
    <use :xlink:href="state.name"></use>
  </svg>
</template>

<script setup lang="ts">
import '../../assets/icons'
import { reactive, defineProps } from 'vue'
import { computed } from '@vue/reactivity'

const props = defineProps({
  name: {
    type: String,
    required: true
  },
  class: {
    type: String,
    default: ''
  }
})

const state = reactive({
  name: `#icon-${props.name}`,
  svgClass: computed(() => 'svg-box ' + props.class)
})
</script>

<style lang="less">
.svg-box {
  width: 1em;
  height: 1em;
  fill: currentColor;
}
</style>
